#!/usr/bin/env node

const https = require('https'),
      log = console.log,
      url = require('url');

let addr = 'https://api.github.com/search/repositories?q=user:wangding';
let options = url.parse(addr);

options.headers = {
  'User-Agent': 'curl'
};

https.get(options,res=>{
  let result = '';
  res.on('data' ,data=>{
    result+=data.toString('utf8');
  })
  res.on('end',()=>{
    let chunk = JSON.parse(result);
    let rs=[];
    let num = 1;
    log(chunk.item);
    process.exit(2);

    chunk.item.forEach((item)=>{
      rs.push({
        num:num++,
        name:item.name,
      })
    })
    log(rs);
  })

});

